<template>
  <a-modal
    title="编辑其他收支"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
  >
    <a-spin :spinning="confirmLoading">
      <div class="main-content">
        <a-row >
          <a-col :span="24" class="content-row">單號：{{ data.no }}</a-col>
          <a-col :span="24" class="content-row">房間：{{ data.roomName }}</a-col>
          <a-col :span="24" class="content-row">租客：{{ data.name }}</a-col>
          <a-col :span="24" class="content-row">類目：{{ data.revenuesTypeName }}</a-col>
          <a-col :span="24" class="content-row">金額：{{ data.amount }}元</a-col>
          <div v-if="data.revenuesStatus === 1">
            <a-col :span="24" class="content-row">收款日期：{{ data.receiveDate }}</a-col>
            <a-col :span="24" class="content-row">收款方式：{{ statusFkfsFilter(data.collectionType) }}</a-col>
            <a-col :span="24" class="content-row">收款經辦人：{{ data.auditName }}</a-col>
          </div>
          <a-col :span="24" class="content-row">經辦人：{{ data.manager }}</a-col>
          <a-col :span="24" class="content-row">經辦時間：{{ data.createTime }}</a-col>
          <a-col :span="24" class="content-row">備註：{{ data.remark }}</a-col>
        </a-row>
      </div>
    </a-spin>
  </a-modal>
</template>

<script>
  import moment from 'moment'
  import { getLookDetail } from '@/api/modular/main/billotherrevenues/billOtherRevenuesManage'
  import { busMeansOfTransactionList } from '@/api/modular/main/busmeansoftransaction/busMeansOfTransactionManage'
  export default {
    data () {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 }
        },
        collectionTypeData: [],
        visible: false,
        confirmLoading: false,
        transactionData: [],
        data: {}
      }
    },
    methods: {
      moment,
      // 初始化方法
      edit (id) {
        this.initData(id)
        this.visible = true
      },
      statusFkfsFilter (id) {
        // eslint-disable-next-line eqeqeq
        const values = this.transactionData.filter(item => item.id == id)
        if (values.length > 0) {
          return values[0].name
        }
      },
      initData(id) {
        busMeansOfTransactionList().then((res) => {
          if (res.code === 200) {
            this.transactionData = res.data
          } else {
            this.$message.error(res.msg)
          }
        })
        getLookDetail(id).then((res) => {
          if (res.code === 200) {
            this.data = res.data
          } else {
            this.$message.error(res.msg) // + res.message
          }
        })
      },
      handleSubmit () {
        this.handleCancel()
      },
      handleCancel () {
        this.data = {}
        this.visible = false
      }
    }
  }
</script>

<style lang="less" scoped>
.main-content{
  padding: 10px 20px;
}
.content-row {
  margin-top: 6px;
}
</style>
